﻿//********************************************************************************//
//创建日期：<创建日期，2016-11-01>
//创建作者：<郭登杰>
//功能说明：来函公共控件-分户申请信息
//********************************************************************************//
using BLL.Access;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Class;
using Entity;
using BLL;
using DevExpress.Web;

namespace Web.Controls.LAIHAN
{
    public partial class UCLHFenHuQS : System.Web.UI.UserControl, IUCLHOperate
    {
        #region 属性

        /// <summary>
        /// 来函类型
        /// </summary>
        public eLaiHanLX LaiHanLX { get; set; }

        /// <summary>
        /// 来函流程
        /// </summary>
        public eLaiHanLCBH LaiHanLC { get; set; }

        /// <summary>


        /// <summary>
        /// 是否详细信息
        /// </summary>
        public bool IsXXXX { get; set; }

        /// <summary>
        /// 记录结果集1
        /// </summary>
        private DataTable dtSource1
        {
            get
            {
                return ViewState["dtSource1"] as DataTable;
            }
            set
            {
                ViewState["dtSource1"] = value;
            }
        }

        /// <summary>
        /// 记录结果集2
        /// </summary>
        private DataTable dtSource2
        {
            get
            {
                return ViewState["dtSource2"] as DataTable;
            }
            set
            {
                ViewState["dtSource2"] = value;
            }
        }

        /// <summary>
        /// 记录结果集3
        /// </summary>
        private DataTable dtSource3
        {
            get
            {
                return ViewState["dtSource3"] as DataTable;
            }
            set
            {
                ViewState["dtSource3"] = value;
            }
        }

        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitControl();
            }
            SetDisplay();
        }

        /// <summary>
        /// 响应前台回调
        /// </summary>
        protected void ASPxCallback1_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            CallbackResult cr = new CallbackResult(e.Parameter);
            if (e.Parameter == "yhh")
            {
                DataRowCollection drc = new QS_YG_YONGHUXXProcess().SelectQS_YG_YONGHUXXesDynamic("I_JLZT=0 AND S_YONGHUH='" + this.txtYongHuHYuan.Text + "'", null).Rows;
                if (drc.Count == 0)
                {
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    cr.Msg = "未查到对应用户";
                    e.Result = cr.ToString();
                    return;
                }
                else
                {
                    cr.IsSuccess = true;
                    cr.IsAlertMsg = false;
                    e.Result = cr.ToString();
                    return;
                }
            }
            else if (e.Parameter == "hth1")
            {
                //获取合同号
                string hetongh = BusinessTool.GetHeTongH(this.txtYHH1.Text);
                cr.IsSuccess = true;
                cr.AddValue(hetongh);
                e.Result = cr.ToString();
            }
            else if (e.Parameter == "hth2")
            {
                //获取合同号
                string hetongh = BusinessTool.GetHeTongH(this.txtYHH2.Text);
                cr.IsSuccess = true;
                cr.AddValue(hetongh);
                e.Result = cr.ToString();
            }
            else if (e.Parameter == "hth3")
            {
                //获取合同号
                string hetongh = BusinessTool.GetHeTongH(this.txtYHH3.Text);
                cr.IsSuccess = true;
                cr.AddValue(hetongh);
                e.Result = cr.ToString();
            }
        }

        #endregion

        #region 方法

        /// <summary>
        /// 配置控件
        /// </summary>
        public void InitControl()
        {
            PageTools.QSLoadCombox(this.cmbZGBM1, PageTools.eLoadType.管理部门QS, null, null);
            PageTools.QSLoadCombox(this.cmbHYFL1, PageTools.eLoadType.行业分类QS, null, null);
            PageTools.QSLoadCombox(this.cmbXZQ1, PageTools.eLoadType.行政区QS, null, null);
            PageTools.QSLoadCombox(this.cmbHXBJ1, PageTools.eLoadType.环线标记QS, null, null);
            PageTools.QSLoadCombox(this.cmbLY1, PageTools.eLoadType.流域QS, null, null);
            PageTools.QSLoadCombox(this.cmbQSYT1, PageTools.eLoadType.取水用途QS, null, null);
            PageTools.QSLoadCombox(this.cmbSLFP1, PageTools.eLoadType.水利分片QS, null, null);
            PageTools.QSLoadCombox(this.cmbSZYFQ1, PageTools.eLoadType.水资源分区QS, null, null);
            PageTools.QSLoadCombox(this.cmbYWY1, PageTools.eLoadType.业务员QS, null, null);
            this.cmbZBJL1.SelectedIndex = 0;
            this.txtHTH1.ClientEnabled = false;

            PageTools.QSLoadCombox(this.cmbZGBM2, PageTools.eLoadType.管理部门QS, null, null);
            PageTools.QSLoadCombox(this.cmbHYFL2, PageTools.eLoadType.行业分类QS, null, null);
            PageTools.QSLoadCombox(this.cmbXZQ2, PageTools.eLoadType.行政区QS, null, null);
            PageTools.QSLoadCombox(this.cmbHXBJ2, PageTools.eLoadType.环线标记QS, null, null);
            PageTools.QSLoadCombox(this.cmbLY2, PageTools.eLoadType.流域QS, null, null);
            PageTools.QSLoadCombox(this.cmbQSYT2, PageTools.eLoadType.取水用途QS, null, null);
            PageTools.QSLoadCombox(this.cmbSLFP2, PageTools.eLoadType.水利分片QS, null, null);
            PageTools.QSLoadCombox(this.cmbSZYFQ2, PageTools.eLoadType.水资源分区QS, null, null);
            PageTools.QSLoadCombox(this.cmbYWY2, PageTools.eLoadType.业务员QS, null, null);
            this.cmbZBJL2.SelectedIndex = 0;
            this.txtHTH2.ClientEnabled = false;

            PageTools.QSLoadCombox(this.cmbZGBM3, PageTools.eLoadType.管理部门QS, null, null);
            PageTools.QSLoadCombox(this.cmbHYFL3, PageTools.eLoadType.行业分类QS, null, null);
            PageTools.QSLoadCombox(this.cmbXZQ3, PageTools.eLoadType.行政区QS, null, null);
            PageTools.QSLoadCombox(this.cmbHXBJ3, PageTools.eLoadType.环线标记QS, null, null);
            PageTools.QSLoadCombox(this.cmbLY3, PageTools.eLoadType.流域QS, null, null);
            PageTools.QSLoadCombox(this.cmbQSYT3, PageTools.eLoadType.取水用途QS, null, null);
            PageTools.QSLoadCombox(this.cmbSLFP3, PageTools.eLoadType.水利分片QS, null, null);
            PageTools.QSLoadCombox(this.cmbSZYFQ3, PageTools.eLoadType.水资源分区QS, null, null);
            PageTools.QSLoadCombox(this.cmbYWY3, PageTools.eLoadType.业务员QS, null, null);
            this.cmbZBJL3.SelectedIndex = 0;
            this.txtHTH3.ClientEnabled = false;

            this.cbQiYongFH3.Checked = false;
            this.btn13.ClientEnabled = false;
            this.btn23.ClientEnabled = false;
            this.btn31.ClientEnabled = false;
            this.btn32.ClientEnabled = false;
        }

        /// <summary>
        /// 设置控件启禁用
        /// </summary>
        /// <param name="enabled"></param>
        private void SetEnabled(bool enabled, int fhNo)
        {
            this.txtShouLiRQ.ClientEnabled = enabled;
            this.txtYeWuY.ClientEnabled = enabled;
            if (fhNo == 1)
            {
                this.txtDZ1.ClientEnabled = enabled;
                this.txtHTH1.ClientEnabled = enabled;
                this.txtKHHM1.ClientEnabled = enabled;
                this.txtKHYH1.ClientEnabled = enabled;
                this.txtKHZH1.ClientEnabled = enabled;
                this.txtLXBM1.ClientEnabled = enabled;
                this.txtLXDH1.ClientEnabled = enabled;
                this.txtLXR1.ClientEnabled = enabled;
                this.txtYeWuY.ClientEnabled = enabled;
                this.txtYHH1.ClientEnabled = enabled;
                this.txtYHM1.ClientEnabled = enabled;
                this.txtYB1.ClientEnabled = enabled;
                this.txtYSJ1.ClientEnabled = enabled;
                this.cmbHYFL1.ClientEnabled = enabled;
                this.cmbXZQ1.ClientEnabled = enabled;
                this.cmbYWY1.ClientEnabled = enabled;
                this.cbTS1.ClientEnabled = enabled;
                this.txtCWDZ1.ClientEnabled = enabled;
                this.txtCWHM1.ClientEnabled = enabled;
                this.txtCWYB1.ClientEnabled = enabled;
                this.cmbHXBJ1.ClientEnabled = enabled;
                this.cmbLY1.ClientEnabled = enabled;
                this.cmbQSYT1.ClientEnabled = enabled;
                this.cmbSLFP1.ClientEnabled = enabled;
                this.cmbSZYFQ1.ClientEnabled = enabled;
                this.cmbZBJL1.ClientEnabled = enabled;
                this.cmbZGBM1.ClientEnabled = enabled;
                this.btn12.ClientEnabled = enabled;
                this.btn13.ClientEnabled = enabled;
            }
            else if (fhNo == 2)
            {
                this.txtDZ2.ClientEnabled = enabled;
                this.txtHTH2.ClientEnabled = enabled;
                this.txtKHHM2.ClientEnabled = enabled;
                this.txtKHYH2.ClientEnabled = enabled;
                this.txtKHZH2.ClientEnabled = enabled;
                this.txtLXBM2.ClientEnabled = enabled;
                this.txtLXDH2.ClientEnabled = enabled;
                this.txtLXR2.ClientEnabled = enabled;
                this.txtYeWuY.ClientEnabled = enabled;
                this.txtYHH2.ClientEnabled = enabled;
                this.txtYHM2.ClientEnabled = enabled;
                this.txtYB2.ClientEnabled = enabled;
                this.txtYSJ2.ClientEnabled = enabled;
                this.cmbHYFL2.ClientEnabled = enabled;
                this.cmbXZQ2.ClientEnabled = enabled;
                this.cmbYWY2.ClientEnabled = enabled;
                this.cbTS2.ClientEnabled = enabled;
                this.txtCWDZ2.ClientEnabled = enabled;
                this.txtCWHM2.ClientEnabled = enabled;
                this.txtCWYB2.ClientEnabled = enabled;
                this.cmbHXBJ2.ClientEnabled = enabled;
                this.cmbLY2.ClientEnabled = enabled;
                this.cmbQSYT2.ClientEnabled = enabled;
                this.cmbSLFP2.ClientEnabled = enabled;
                this.cmbSZYFQ2.ClientEnabled = enabled;
                this.cmbZBJL2.ClientEnabled = enabled;
                this.cmbZGBM2.ClientEnabled = enabled;
                this.btn21.ClientEnabled = enabled;
                this.btn23.ClientEnabled = enabled;
            }
            else if (fhNo == 3)
            {
                this.txtDZ3.ClientEnabled = enabled;
                this.txtHTH3.ClientEnabled = enabled;
                this.txtKHHM3.ClientEnabled = enabled;
                this.txtKHYH3.ClientEnabled = enabled;
                this.txtKHZH3.ClientEnabled = enabled;
                this.txtLXBM3.ClientEnabled = enabled;
                this.txtLXDH3.ClientEnabled = enabled;
                this.txtLXR3.ClientEnabled = enabled;
                this.txtYeWuY.ClientEnabled = enabled;
                this.txtYHH3.ClientEnabled = enabled;
                this.txtYHM3.ClientEnabled = enabled;
                this.txtYB3.ClientEnabled = enabled;
                this.txtYSJ3.ClientEnabled = enabled;
                this.cmbHYFL3.ClientEnabled = enabled;
                this.cmbXZQ3.ClientEnabled = enabled;
                this.cmbYWY3.ClientEnabled = enabled;
                this.cbTS3.ClientEnabled = enabled;
                this.txtCWDZ3.ClientEnabled = enabled;
                this.txtCWHM3.ClientEnabled = enabled;
                this.txtCWYB3.ClientEnabled = enabled;
                this.cmbHXBJ3.ClientEnabled = enabled;
                this.cmbLY3.ClientEnabled = enabled;
                this.cmbQSYT3.ClientEnabled = enabled;
                this.cmbSLFP3.ClientEnabled = enabled;
                this.cmbSZYFQ3.ClientEnabled = enabled;
                this.cmbZBJL3.ClientEnabled = enabled;
                this.cmbZGBM3.ClientEnabled = enabled;
                this.btn31.ClientEnabled = enabled;
                this.btn32.ClientEnabled = enabled;
            }
        }

        /// <summary>
        ///根据当前流程状态设置步骤显示
        /// </summary>
        private void SetDisplay()
        {
            //先隐藏所有
            this.tabTopInfo.Visible = false;
            this.tabUserInfo.Visible = false;
            this.trYH1ZGBM.Visible = (BusinessTool.WType == 2);
            this.trYH2ZGBM.Visible = (BusinessTool.WType == 2);
            this.trYH3ZGBM.Visible = (BusinessTool.WType == 2);
            //根据来函显示面板
            //根据来函类型及当前流程显示意意见量
            if (this.LaiHanLC <= eLaiHanLCBH.预登记)
            {
                this.tabUserInfo.Visible = true;
                SetEnabled(true, 1);
                SetEnabled(true, 2);
                SetEnabled(this.cbQiYongFH3.Checked, 3);
                this.txtYongHuHYuan.ClientEnabled = true;
                this.cbQiYongFH3.ClientEnabled = true;
            }
            else if (this.LaiHanLC == eLaiHanLCBH.登记)
            {
                this.tabUserInfo.Visible = true;
                SetEnabled(false, 1);
                SetEnabled(false, 2);
                SetEnabled(false, 3);
                this.txtYongHuHYuan.ClientEnabled = false;
                this.cbQiYongFH3.ClientEnabled = false;
            }
            else if ((int)this.LaiHanLC >= (int)eLaiHanLCBH.业务员)
            {
                this.tabTopInfo.Visible = false;
                this.tabUserInfo.Visible = true;
                SetEnabled(false, 1);
                SetEnabled(false, 2);
                SetEnabled(false, 3);
                this.txtYongHuHYuan.ClientEnabled = false;
                this.cbQiYongFH3.Visible = false;
                this.btn12.Visible = false;
                this.btn13.Visible = false;
                this.btn21.Visible = false;
                this.btn23.Visible = false;
                this.btn31.Visible = false;
                this.btn32.Visible = false;
            }
        }

        /// <summary>
        /// 提交验证
        /// </summary>
        ValidateRS IUCLHOperate.Validate()
        {
            ValidateRS rs = new ValidateRS();
            if (this.txtYHH1.Text == "")
            {
                rs.Msg = "请输入分户1用户号！";
                return rs;
            }
            if (this.txtYHH1.Text.Length != 7)
            {
                rs.Msg = "用户号的长度应为7位！";
                return rs;
            }
            //分户1用户号允许为原用户
            if (this.txtYHM1.Text == "")
            {
                rs.Msg = "分户1用户名不能为空！";
                return rs;
            }
            if (this.cmbXZQ1.Text == "")
            {
                rs.Msg = "请选择行政区！";
                return rs;
            }
            if (this.cmbYWY1.Text == "")
            {
                rs.Msg = "请选择业务员！";
                return rs;
            }
            if (this.txtDZ1.Text == "")
            {
                rs.Msg = "用户地址不能为空！";
                return rs;
            }
            if (this.txtYB1.Text == "")
            {
                rs.Msg = "邮编不能为空！";
                return rs;
            }
            if (this.txtYSJ1.Text == "")
            {
                rs.Msg = "用水价不能为空！";
                return rs;
            }
            if (!PageTools.ValidateString(this.txtYSJ1.Text, PageTools.eValidateType.水价))
            {
                rs.Msg = "请输入正确的用水价！";
                return rs;
            }
            //如果为托收,需要填写银行账号,开户银行,开户户名
            if (this.cbTS1.Checked)
            {
                if (this.txtKHYH1.Text == "")
                {
                    rs.Msg = "开户银行不能为空！";
                    return rs;
                }
                if (this.txtKHZH1.Text == "")
                {
                    rs.Msg = "银行账号不能为空！";
                    return rs;
                }
                if (this.txtKHHM1.Text == "")
                {
                    rs.Msg = "开户户名不能为空！";
                    return rs;
                }
                if (!PageTools.ValidateString(this.txtKHZH1.Text, PageTools.eValidateType.数字))
                {
                    rs.Msg = "请输入正确的银行账号！";
                    return rs;
                }
            }
            if (this.txtYHH2.Text == "")
            {
                rs.Msg = "请输入分户2用户号！";
                return rs;
            }
            if (this.txtYHH2.Text.Length != 7)
            {
                rs.Msg = "用户号的长度应为7位！";
                return rs;
            }
            //判断用户号是否重复
            if (new QS_YG_YONGHUXXBLL().SelectQS_YG_YONGHUXXesDynamic(string.Format("I_JLZT=0 and S_YONGHUH='{0}'", this.txtYHH2.Text), null).Rows.Count > 0)
            {
                rs.Msg = "分户2用户号系统中已有使用,请更换！";
                return rs;
            }
            if (this.txtYHM2.Text == "")
            {
                rs.Msg = "分户2用户名不能为空！";
                return rs;
            }
            if (this.cmbXZQ2.Text == "")
            {
                rs.Msg = "请选择行政区！";
                return rs;
            }
            if (this.cmbYWY2.Text == "")
            {
                rs.Msg = "请选择业务员！";
                return rs;
            }
            if (this.txtDZ2.Text == "")
            {
                rs.Msg = "用户地址不能为空！";
                return rs;
            }
            if (this.txtYB2.Text == "")
            {
                rs.Msg = "邮编不能为空！";
                return rs;
            }
            if (this.txtYSJ2.Text == "")
            {
                rs.Msg = "用水价不能为空！";
                return rs;
            }
            if (!PageTools.ValidateString(this.txtYSJ2.Text, PageTools.eValidateType.水价))
            {
                rs.Msg = "请输入正确的用水价！";
                return rs;
            }
            //如果为托收,需要填写银行账号,开户银行,开户户名
            if (this.cbTS2.Checked)
            {
                if (this.txtKHYH2.Text == "")
                {
                    rs.Msg = "开户银行不能为空！";
                    return rs;
                }
                if (this.txtKHZH2.Text == "")
                {
                    rs.Msg = "银行账号不能为空！";
                    return rs;
                }
                if (this.txtKHHM2.Text == "")
                {
                    rs.Msg = "开户户名不能为空！";
                    return rs;
                }
                if (!PageTools.ValidateString(this.txtKHZH2.Text, PageTools.eValidateType.数字))
                {
                    rs.Msg = "请输入正确的银行账号！";
                    return rs;
                }
            }
            if (this.cbQiYongFH3.Checked)
            {
                if (this.txtYHH3.Text == "")
                {
                    rs.Msg = "请输入分户3用户号！";
                    return rs;
                }
                if (this.txtYHH3.Text.Length != 7)
                {
                    rs.Msg = "用户号的长度应为7位！";
                    return rs;
                }
                //判断用户号是否重复
                if (new QS_YG_YONGHUXXBLL().SelectQS_YG_YONGHUXXesDynamic(string.Format("I_JLZT=0 and S_YONGHUH='{0}'", this.txtYHH3.Text), null).Rows.Count > 0)
                {
                    rs.Msg = "分户3用户号系统中已有使用,请更换！";
                    return rs;
                }
                if (this.txtYHM3.Text == "")
                {
                    rs.Msg = "分户3用户名不能为空！";
                    return rs;
                }
                if (this.cmbXZQ3.Text == "")
                {
                    rs.Msg = "请选择行政区！";
                    return rs;
                }
                if (this.cmbYWY3.Text == "")
                {
                    rs.Msg = "请选择业务员！";
                    return rs;
                }
                if (this.txtDZ3.Text == "")
                {
                    rs.Msg = "用户地址不能为空！";
                    return rs;
                }
                if (this.txtYB3.Text == "")
                {
                    rs.Msg = "邮编不能为空！";
                    return rs;
                }
                if (this.txtYSJ3.Text == "")
                {
                    rs.Msg = "用水价不能为空！";
                    return rs;
                }
                if (!PageTools.ValidateString(this.txtYSJ3.Text, PageTools.eValidateType.水价))
                {
                    rs.Msg = "请输入正确的用水价！";
                    return rs;
                }
                //如果为托收,需要填写银行账号,开户银行,开户户名
                if (this.cbTS3.Checked)
                {
                    if (this.txtKHYH3.Text == "")
                    {
                        rs.Msg = "开户银行不能为空！";
                        return rs;
                    }
                    if (this.txtKHZH3.Text == "")
                    {
                        rs.Msg = "银行账号不能为空！";
                        return rs;
                    }
                    if (this.txtKHHM3.Text == "")
                    {
                        rs.Msg = "开户户名不能为空！";
                        return rs;
                    }
                    if (!PageTools.ValidateString(this.txtKHZH3.Text, PageTools.eValidateType.数字))
                    {
                        rs.Msg = "请输入正确的银行账号！";
                        return rs;
                    }
                }
            }
            rs.IsSuccess = true;
            return rs;
        }

        /// <summary>
        /// 判断是否需要变更
        /// </summary>
        /// <returns></returns>
        public ValidateRS ValidateNeedBG(YS_LH_LAIHANXX laihanxx)
        {
            ValidateRS rs = new ValidateRS();

            rs.IsSuccess = true;
            return rs;
        }

        /// <summary>
        /// 清空数据
        /// </summary>
        public void ClearInfo()
        {
            this.cbQiYongFH3.Checked = false;
            this.txtShouLiRQ.Text = "";
            this.txtDZ1.Text = "";
            this.txtHTH1.Text = "";
            this.txtKHHM1.Text = "";
            this.txtKHYH1.Text = "";
            this.txtKHZH1.Text = "";
            this.txtLXBM1.Text = "";
            this.txtLXDH1.Text = "";
            this.txtLXR1.Text = "";
            this.txtYeWuY.Text = "";
            this.txtYHH1.Text = "";
            this.txtYHM1.Text = "";
            this.txtYB1.Text = "";
            this.txtYSJ1.Text = "";
            this.cmbHYFL1.SelectedIndex = 0;
            this.cmbXZQ1.SelectedIndex = 0;
            this.cmbYWY1.SelectedIndex = 0;
            this.cbTS1.Checked = false;
            this.txtCWDZ1.Text = "";
            this.txtCWHM1.Text = "";
            this.txtCWYB1.Text = "";

            this.txtDZ2.Text = "";
            this.txtHTH2.Text = "";
            this.txtKHHM2.Text = "";
            this.txtKHYH2.Text = "";
            this.txtKHZH2.Text = "";
            this.txtLXBM2.Text = "";
            this.txtLXDH2.Text = "";
            this.txtLXR2.Text = "";
            this.txtYeWuY.Text = "";
            this.txtYHH2.Text = "";
            this.txtYHM2.Text = "";
            this.txtYB2.Text = "";
            this.txtYSJ2.Text = "";
            this.cmbHYFL2.SelectedIndex = 0;
            this.cmbXZQ2.SelectedIndex = 0;
            this.cmbYWY2.SelectedIndex = 0;
            this.cbTS2.Checked = false;
            this.txtCWDZ2.Text = "";
            this.txtCWHM2.Text = "";
            this.txtCWYB2.Text = "";

            this.txtDZ3.Text = "";
            this.txtHTH3.Text = "";
            this.txtKHHM3.Text = "";
            this.txtKHYH3.Text = "";
            this.txtKHZH3.Text = "";
            this.txtLXBM3.Text = "";
            this.txtLXDH3.Text = "";
            this.txtLXR3.Text = "";
            this.txtYeWuY.Text = "";
            this.txtYHH3.Text = "";
            this.txtYHM3.Text = "";
            this.txtYB3.Text = "";
            this.txtYSJ3.Text = "";
            this.cmbHYFL3.SelectedIndex = 0;
            this.cmbXZQ3.SelectedIndex = 0;
            this.cmbYWY3.SelectedIndex = 0;
            this.cbTS3.Checked = false;
            this.txtCWDZ3.Text = "";
            this.txtCWHM3.Text = "";
            this.txtCWYB3.Text = "";

            this.txtLaiHanBH.Text = "";
            this.txtShouLiRQ.Text = "";
            this.txtYongHuHYuan.Text = "";

            this.dtSource1 = null;
            this.dtSource2 = null;
            this.dtSource3 = null;
            this.BindData1();
            this.BindData2();
            this.BindData3();
        }


        /// <summary>
        /// 根据来函加载信息
        /// </summary>
        /// <param name="laihanxx"></param>
        public void LoadInfo(YS_LH_LAIHANXX laihanxx)
        {
            if (laihanxx.ID == 0)
            {
                this.LaiHanLC = eLaiHanLCBH.未登记;
                SetDisplay();
                return;
            }
            else
            {
                this.LaiHanLC = (eLaiHanLCBH)Enum.Parse(typeof(eLaiHanLCBH), laihanxx.I_LIUCHENGBH.ToString());
                SetDisplay();
            }
            QS_LH_YONGHUTZProcess bllT = new QS_LH_YONGHUTZProcess();
            //加载原用户
            this.txtYongHuHYuan.Text = laihanxx.S_YONGHUBH;
            this.txtLaiHanBH.Text = laihanxx.S_LAIHANBH;
            //获取分户结果用户列表
            DataRowCollection drc = bllT.SelectQS_LH_YONGHUTZsDynamic("I_JLZT=0 AND S_LAIHANBH=" + laihanxx.S_LAIHANBH + " and I_YUANYONGH=0", "I_NO ASC").Rows;
            for (int i = 0; i < drc.Count; i++)
            {
                DataRow drTemp = drc[i];
                if (drTemp["I_NO"].ToString() == "1")
                {
                    this.txtDZ1.Text = Convert.ToString(drTemp["S_DiZhi"]);
                    this.txtHTH1.Text = Convert.ToString(drTemp["S_HETONGH"]);
                    this.txtKHHM1.Text = Convert.ToString(drTemp["S_KAIHUHM"]);
                    this.txtKHYH1.Text = Convert.ToString(drTemp["S_KAIHUYH"]);
                    this.txtKHZH1.Text = Convert.ToString(drTemp["S_KAIHUH"]);
                    this.txtLXBM1.Text = Convert.ToString(drTemp["S_LIANXIBM"]);
                    this.txtLXDH1.Text = Convert.ToString(drTemp["S_DIANHUA"]);
                    this.txtLXR1.Text = Convert.ToString(drTemp["S_LIANXIR"]);
                    this.txtYHH1.Text = Convert.ToString(drTemp["S_YONGHUH"]);
                    this.txtYHM1.Text = Convert.ToString(drTemp["S_YONGHUM"]);
                    this.txtYB1.Text = Convert.ToString(drTemp["S_YOUBIAN"]);
                    this.txtYSJ1.Text = Convert.ToString(drTemp["N_SHUIJIA"]);
                    this.cbTS1.Checked = drTemp["S_FEETYPE"] == DBNull.Value ? false : (Convert.ToInt32(drTemp["S_FEETYPE"]) == 1);
                    this.cmbXZQ1.Value = Convert.ToString(drTemp["S_XINGZHENGQBH"]);
                    this.cmbYWY1.Value = Convert.ToString(drTemp["S_YEWUY"]);
                    this.cmbHXBJ1.Value = Convert.ToString(drTemp["S_HUANXIANBJ"]);
                    this.cmbLY1.Value = Convert.ToString(drTemp["S_LIUYUBH"]);
                    this.cmbQSYT1.Value = Convert.ToString(drTemp["S_QUSHUIYTBH"]);
                    this.cmbSLFP1.Value = Convert.ToString(drTemp["S_FENPIANBH"]);
                    this.cmbSZYFQ1.Value = Convert.ToString(drTemp["S_SHUIZIYBH"]);
                    this.cmbZBJL1.Value = Convert.ToString(drTemp["S_ZHUANGBIAOJL"]);
                    this.cmbZGBM1.Value = Convert.ToString(drTemp["S_BUMENBH"]);
                    this.dtSource1 = new SpHelper().P_QSLH_FENHUSBGXHQ(laihanxx.S_LAIHANBH, this.txtYHH1.Text).Tables[0];
                    this.BindData1();
                }
                else if (drTemp["I_NO"].ToString() == "2")
                {
                    this.txtDZ2.Text = Convert.ToString(drTemp["S_DiZhi"]);
                    this.txtHTH2.Text = Convert.ToString(drTemp["S_HETONGH"]);
                    this.txtKHHM2.Text = Convert.ToString(drTemp["S_KAIHUHM"]);
                    this.txtKHYH2.Text = Convert.ToString(drTemp["S_KAIHUYH"]);
                    this.txtKHZH2.Text = Convert.ToString(drTemp["S_KAIHUH"]);
                    this.txtLXBM2.Text = Convert.ToString(drTemp["S_LIANXIBM"]);
                    this.txtLXDH2.Text = Convert.ToString(drTemp["S_DIANHUA"]);
                    this.txtLXR2.Text = Convert.ToString(drTemp["S_LIANXIR"]);
                    this.txtYHH2.Text = Convert.ToString(drTemp["S_YONGHUH"]);
                    this.txtYHM2.Text = Convert.ToString(drTemp["S_YONGHUM"]);
                    this.txtYB2.Text = Convert.ToString(drTemp["S_YOUBIAN"]);
                    this.txtYSJ2.Text = Convert.ToString(drTemp["N_SHUIJIA"]);
                    this.cbTS2.Checked = drTemp["S_FEETYPE"] == DBNull.Value ? false : (Convert.ToInt32(drTemp["S_FEETYPE"]) == 1);
                    this.cmbXZQ2.Value = Convert.ToString(drTemp["S_XINGZHENGQBH"]);
                    this.cmbYWY2.Value = Convert.ToString(drTemp["S_YEWUY"]);
                    this.cmbHXBJ2.Value = Convert.ToString(drTemp["S_HUANXIANBJ"]);
                    this.cmbLY2.Value = Convert.ToString(drTemp["S_LIUYUBH"]);
                    this.cmbQSYT2.Value = Convert.ToString(drTemp["S_QUSHUIYTBH"]);
                    this.cmbSLFP2.Value = Convert.ToString(drTemp["S_FENPIANBH"]);
                    this.cmbSZYFQ2.Value = Convert.ToString(drTemp["S_SHUIZIYBH"]);
                    this.cmbZBJL2.Value = Convert.ToString(drTemp["S_ZHUANGBIAOJL"]);
                    this.cmbZGBM2.Value = Convert.ToString(drTemp["S_BUMENBH"]);
                    this.dtSource2 = new SpHelper().P_QSLH_FENHUSBGXHQ(laihanxx.S_LAIHANBH, this.txtYHH2.Text).Tables[0];
                    this.BindData2();
                }
                else if (drTemp["I_NO"].ToString() == "3")
                {
                    this.cbQiYongFH3.Checked = true;
                    this.txtDZ3.Text = Convert.ToString(drTemp["S_DiZhi"]);
                    this.txtHTH3.Text = Convert.ToString(drTemp["S_HETONGH"]);
                    this.txtKHHM3.Text = Convert.ToString(drTemp["S_KAIHUHM"]);
                    this.txtKHYH3.Text = Convert.ToString(drTemp["S_KAIHUYH"]);
                    this.txtKHZH3.Text = Convert.ToString(drTemp["S_KAIHUH"]);
                    this.txtLXBM3.Text = Convert.ToString(drTemp["S_LIANXIBM"]);
                    this.txtLXDH3.Text = Convert.ToString(drTemp["S_DIANHUA"]);
                    this.txtLXR3.Text = Convert.ToString(drTemp["S_LIANXIR"]);
                    this.txtYHH3.Text = Convert.ToString(drTemp["S_YONGHUH"]);
                    this.txtYHM3.Text = Convert.ToString(drTemp["S_YONGHUM"]);
                    this.txtYB3.Text = Convert.ToString(drTemp["S_YOUBIAN"]);
                    this.txtYSJ3.Text = Convert.ToString(drTemp["N_SHUIJIA"]);
                    this.cbTS3.Checked = drTemp["S_FEETYPE"] == DBNull.Value ? false : (Convert.ToInt32(drTemp["S_FEETYPE"]) == 1);
                    this.cmbXZQ3.Value = Convert.ToString(drTemp["S_XINGZHENGQBH"]);
                    this.cmbYWY3.Value = Convert.ToString(drTemp["S_YEWUY"]);
                    this.cmbHXBJ3.Value = Convert.ToString(drTemp["S_HUANXIANBJ"]);
                    this.cmbLY3.Value = Convert.ToString(drTemp["S_LIUYUBH"]);
                    this.cmbQSYT3.Value = Convert.ToString(drTemp["S_QUSHUIYTBH"]);
                    this.cmbSLFP3.Value = Convert.ToString(drTemp["S_FENPIANBH"]);
                    this.cmbSZYFQ3.Value = Convert.ToString(drTemp["S_SHUIZIYBH"]);
                    this.cmbZBJL3.Value = Convert.ToString(drTemp["S_ZHUANGBIAOJL"]);
                    this.cmbZGBM3.Value = Convert.ToString(drTemp["S_BUMENBH"]);
                    this.dtSource3 = new SpHelper().P_QSLH_FENHUSBGXHQ(laihanxx.S_LAIHANBH, this.txtYHH3.Text).Tables[0];
                    this.BindData3();
                }
                if (this.txtYHH3.Text == "")
                {
                    this.td_FenHu3.Visible = false;
                    this.td_FenHu1.Style["width"] = "50%";
                    this.td_FenHu2.Style["width"] = "50%";
                    this.tdList3.Visible = false;
                    this.tdList1.Style["width"] = "50%";
                    this.tdList2.Style["width"] = "50%";
                }
            }

            //获取受理日期等
            DataRow dr = new SpHelper().P_YS_LHGETINFODETAIL(laihanxx.S_LAIHANBH, (int)laihanxx.I_LAIHANLX).Tables[0].Rows[0];
            this.txtShouLiRQ.Text = dr["D_SHOULIRQ"] == DBNull.Value ? "" : Convert.ToDateTime(dr["D_SHOULIRQ"]).ToString("yyyy-MM-dd");
            this.txtYeWuY.Text = Convert.ToString(dr["S_YWY"]);
        }

        /// <summary>
        ///重新绑定分户1水表
        /// </summary>
        public void BindData1()
        {
            this.gvList1.DataSource = this.dtSource1;
            this.gvList1.DataBind();
            //控制复选框列
            for (int i = 0; i < this.gvList1.VisibleRowCount; i++)
            {
                ASPxCheckBox cb = (ASPxCheckBox)gvList1.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList1.Columns[0], "cb");
                cb.Visible = this.txtYHH1.ClientEnabled;
            }
        }
        /// <summary>
        ///重新绑定分户2水表
        /// </summary>
        public void BindData2()
        {
            this.gvList2.DataSource = this.dtSource2;
            this.gvList2.DataBind();
            //控制复选框列
            for (int i = 0; i < this.gvList2.VisibleRowCount; i++)
            {
                ASPxCheckBox cb = (ASPxCheckBox)gvList2.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList2.Columns[0], "cb");
                cb.Visible = this.txtYHH2.ClientEnabled; ;
            }
        }
        /// <summary>
        ///重新绑定分户3水表
        /// </summary>
        public void BindData3()
        {
            this.gvList3.DataSource = this.dtSource3;
            this.gvList3.DataBind();
            //控制复选框列
            for (int i = 0; i < this.gvList3.VisibleRowCount; i++)
            {
                ASPxCheckBox cb = (ASPxCheckBox)gvList3.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList3.Columns[0], "cb");
                cb.Visible = this.txtYHH3.ClientEnabled; ;
            }
        }

        /// <summary>
        /// 获取来函主表信息
        /// </summary>
        /// <param name="liuchengzt">0:收件 1:收件并登记</param>
        /// <param name="msg">输出消息,正常为空</param>
        /// <returns>null:验证失败 !null:成功返回</returns>
        public YS_LH_LAIHANXX GetLAIHANXX(int laihanid, int liuchengzt, out string msg)
        {
            YS_LH_LAIHANXX laihan = new YS_LH_LAIHANXX();
            string laihanbh = "";
            string xukebh = "";
            msg = "";
            if (laihanid == 0)
            {
                string zd, glk, ywy;
                PageTools.GetLHDJZDGLKYWY(this.txtYongHuHYuan.Text, out zd, out glk, out ywy);
                laihan.S_ZHANDIANBH = zd;
                laihan.S_GUANLIKBH = glk;
                laihan.I_YWY = int.Parse(ywy);
                laihan.S_YWY = BusinessTool.GetYWYName(ywy);
                //laihan.S_YHYWY = ywy;
                laihan.ID = 0;
                //DataSet numset = new SpHelper().P_YS_LH_XUKEBH(glk, (int)this.LaiHanLX, 0, (BusinessTool.GetWaterYM() / 100).ToString(), out xukebh, out laihanbh);
                new SpHelper().P_ALL_LH_BHSC(BusinessTool.WType, (int)this.LaiHanLX, BusinessTool.GetWaterYM() / 100, out laihanbh);
                laihan.I_XT = BusinessTool.WType;
                laihan.D_SHURURQ = DateTime.Now;
                laihan.D_LAIHANRQ = DateTime.Now;
                laihan.I_JLZT = 0;
                laihan.I_LAIHANLX = (int)this.LaiHanLX;
                laihan.I_SHURUR = LoginInfo.CurrentUser.UserID;
                laihan.I_AUTOTYPE = 0;
                laihan.S_LAIHANBH = laihanbh;
                laihan.S_BEIYONG1 = xukebh;
                laihan.S_XUKEBH = xukebh;
                laihan.S_YONGHUBH = this.txtYongHuHYuan.Text;
                laihan.I_Y = BusinessTool.GetWaterYM() / 100;
                laihan.I_M = BusinessTool.GetWaterYM() % 100;
            }
            else
            {
                laihan = new YS_LH_LAIHANXXProcess().SelectYS_LH_LAIHANXX(laihanid);
            }
            laihan.I_LIUCHENGBH = liuchengzt;
            laihan.I_LIUCHENGZT = (int)eLaiHanLCZT.流程中;
            laihan.S_CAOZUOR = LoginInfo.CurrentUser.UserID.ToString();
            laihan.D_CAOZUOSJ = BusinessTool.GetDataBaseDateTime();
            return laihan;
        }

        /// <summary>
        /// 添加申请信息
        /// </summary>
        /// <param name="laihanxx"></param>
        public void CreateShengQingXX(YS_LH_LAIHANXX laihanxx)
        {
            //清除用户变更表
            QS_LH_YONGHUTZProcess bllyhtz = new QS_LH_YONGHUTZProcess();
            bllyhtz.DeleteQS_LH_YONGHUTZsDynamic("S_LAIHANBH=" + laihanxx.S_LAIHANBH);
            //更新用户变更表
            List<QS_LH_YONGHUTZ> yhtzList = this.GetLHYONGHUTZ(laihanxx);
            foreach (QS_LH_YONGHUTZ item in yhtzList)
            {
                bllyhtz.InsertOrUpdate(item);
            }
            //清除分户水表关系表
            QS_LH_FENHUSBGXProcess bllt2 = new QS_LH_FENHUSBGXProcess();
            bllt2.DeleteQS_LH_FENHUSBGXesDynamic("S_LAIHANBH=" + laihanxx.S_LAIHANBH);
            //重新添加分户水表关系
            if (this.dtSource1 != null && this.dtSource1.Rows.Count > 0)
            {
                for (int i = 0; i < this.dtSource1.Rows.Count; i++)
                {
                    QS_LH_FENHUSBGX item = new QS_LH_FENHUSBGX();
                    item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                    item.S_SHUIBIAOBH = this.dtSource1.Rows[i]["S_SHUIBIAOH"].ToString();
                    item.S_JINBH = this.dtSource1.Rows[i]["S_QUSHUIK"].ToString();
                    item.S_YONGHUH = this.txtYHH1.Text;
                    bllt2.InsertOrUpdate(item);
                }
            }
            if (this.dtSource2 != null && this.dtSource2.Rows.Count > 0)
            {
                for (int i = 0; i < this.dtSource2.Rows.Count; i++)
                {
                    QS_LH_FENHUSBGX item = new QS_LH_FENHUSBGX();
                    item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                    item.S_SHUIBIAOBH = this.dtSource2.Rows[i]["S_SHUIBIAOH"].ToString();
                    item.S_YONGHUH = this.txtYHH2.Text;
                    item.S_JINBH = this.dtSource2.Rows[i]["S_QUSHUIK"].ToString();
                    bllt2.InsertOrUpdate(item);
                }
            }
            if (this.dtSource3 != null && this.dtSource3.Rows.Count > 0)
            {
                for (int i = 0; i < this.dtSource3.Rows.Count; i++)
                {
                    QS_LH_FENHUSBGX item = new QS_LH_FENHUSBGX();
                    item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                    item.S_SHUIBIAOBH = this.dtSource3.Rows[i]["S_SHUIBIAOH"].ToString();
                    item.S_JINBH = this.dtSource3.Rows[i]["S_QUSHUIK"].ToString();
                    item.S_YONGHUH = this.txtYHH3.Text;
                    bllt2.InsertOrUpdate(item);
                }
            }
        }

        /// <summary>
        /// 获取来函用户调整
        /// </summary>
        /// <returns></returns>
        public List<QS_LH_YONGHUTZ> GetLHYONGHUTZ(YS_LH_LAIHANXX laihanxx)
        {
            List<QS_LH_YONGHUTZ> list = new List<QS_LH_YONGHUTZ>();
            //添加原用户
            list.Add(CreateYuanYongHu(laihanxx));
            //添加分户1
            QS_LH_YONGHUTZ yhxx1 = new QS_LH_YONGHUTZ();
            yhxx1.I_NO = 1;
            yhxx1.D_CAOZUORQ = BusinessTool.GetDataBaseDateTime();
            yhxx1.D_TIANJIARQ = yhxx1.D_CAOZUORQ;
            yhxx1.I_BIAOSHI = (cbTS1.Checked == true ? 1 : 0);
            yhxx1.I_JLZT = 0;
            yhxx1.I_LAIHANLX = (int)this.LaiHanLX;
            yhxx1.I_WTYPE = BusinessTool.WType;
            yhxx1.I_YUANYONGH = 0;
            yhxx1.ID = 0;
            yhxx1.N_SHUIJIA = Convert.ToDecimal(this.txtYSJ1.Text);
            yhxx1.S_BUMENBH = BusinessTool.WType==2?Convert.ToString(this.cmbZGBM1.Value):"600";
            yhxx1.S_CAIWUDZ = this.txtCWDZ1.Text;
            yhxx1.S_CAIWUHM = this.txtCWHM1.Text;
            yhxx1.S_CAIWUYB = this.txtCWYB1.Text;
            yhxx1.S_CAOZUOR = LoginInfo.CurrentUser.UserID.ToString();
            yhxx1.S_DESTUSER = null;
            yhxx1.S_DIANHUA = this.txtLXDH1.Text;
            yhxx1.S_DIZHI = this.txtDZ1.Text;
            //yhxx1.S_FEETYPE = (this.cbTS1.Checked ? "1" : "0");
            yhxx1.S_FENPIANBH = Convert.ToString(this.cmbSLFP1.Value);
            yhxx1.S_HANGYEBH = Convert.ToString(this.cmbHYFL1.Value);
            yhxx1.S_HETONGH = Convert.ToString(this.txtHTH1.Text);
            yhxx1.S_HUANXIANBJ = Convert.ToString(this.cmbHXBJ1.Value);
            yhxx1.S_JIESHUNY = null;
            yhxx1.S_KAIHUH = this.txtKHZH1.Text;
            yhxx1.S_KAIHUHM = this.txtKHHM1.Text;
            yhxx1.S_KAIHUYH = this.txtKHYH1.Text;
            yhxx1.S_KAISHINY = null;
            yhxx1.S_LAIHANBH = laihanxx.S_LAIHANBH;
            yhxx1.S_LIANXIBM = this.txtLXBM1.Text;
            yhxx1.S_LIANXIR = this.txtLXR1.Text;
            yhxx1.S_LIUYUBH = Convert.ToString(this.cmbLY1.Value);
            yhxx1.S_QUSHUIYTBH = Convert.ToString(this.cmbQSYT1.Value);
            yhxx1.S_SHUIZIYBH = Convert.ToString(this.cmbSZYFQ1.Value);
            yhxx1.S_TIANJIAR = LoginInfo.CurrentUser.UserID.ToString();
            yhxx1.S_XINGZHENGQBH = this.cmbXZQ1.Value.ToString();
            yhxx1.S_YEWUY = this.cmbYWY1.Value.ToString();
            yhxx1.S_YINHANG = null;
            yhxx1.S_YONGHUH = this.txtYHH1.Text;
            yhxx1.S_YONGHUM = this.txtYHM1.Text;
            yhxx1.S_YOUBIAN = this.txtYB1.Text;
            yhxx1.S_YUANYONGHUH = laihanxx.S_YONGHUBH;
            yhxx1.S_ZHUANGBIAOJL = Convert.ToString(this.cmbZBJL1.Value);
            yhxx1.S_ZHUSHI = null;
            list.Add(yhxx1);
            //添加分户2
            QS_LH_YONGHUTZ yhxx2 = new QS_LH_YONGHUTZ();
            yhxx2.I_NO = 2;
            yhxx2.D_CAOZUORQ = BusinessTool.GetDataBaseDateTime();
            yhxx2.D_TIANJIARQ = yhxx2.D_CAOZUORQ;
            yhxx2.I_BIAOSHI = (this.cbTS2.Checked ? 1 : 0);
            yhxx2.I_JLZT = 0;
            yhxx2.I_LAIHANLX = (int)this.LaiHanLX;
            yhxx2.I_WTYPE = BusinessTool.WType;
            yhxx2.I_YUANYONGH = 0;
            yhxx2.ID = 0;
            yhxx2.N_SHUIJIA = Convert.ToDecimal(this.txtYSJ2.Text);
            yhxx2.S_BUMENBH = BusinessTool.WType == 2 ? Convert.ToString(this.cmbZGBM2.Value) : "600";
            yhxx2.S_CAIWUDZ = this.txtCWDZ2.Text;
            yhxx2.S_CAIWUHM = this.txtCWHM2.Text;
            yhxx2.S_CAIWUYB = this.txtCWYB2.Text;
            yhxx2.S_CAOZUOR = LoginInfo.CurrentUser.UserID.ToString();
            yhxx2.S_DESTUSER = null;
            yhxx2.S_DIANHUA = this.txtLXDH2.Text;
            yhxx2.S_DIZHI = this.txtDZ2.Text;
            //yhxx2.S_FEETYPE = (this.cbTS2.Checked ? "2" : "0");
            yhxx2.S_FENPIANBH = Convert.ToString(this.cmbSLFP2.Value);
            yhxx2.S_HANGYEBH = Convert.ToString(this.cmbHYFL2.Value);
            yhxx2.S_HETONGH = Convert.ToString(this.txtHTH2.Text);
            yhxx2.S_HUANXIANBJ = Convert.ToString(this.cmbHXBJ2.Value);
            yhxx2.S_JIESHUNY = null;
            yhxx2.S_KAIHUH = this.txtKHZH2.Text;
            yhxx2.S_KAIHUHM = this.txtKHHM2.Text;
            yhxx2.S_KAIHUYH = this.txtKHYH2.Text;
            yhxx2.S_KAISHINY = null;
            yhxx2.S_LAIHANBH = laihanxx.S_LAIHANBH;
            yhxx2.S_LIANXIBM = this.txtLXBM2.Text;
            yhxx2.S_LIANXIR = this.txtLXR2.Text;
            yhxx2.S_LIUYUBH = Convert.ToString(this.cmbLY2.Value);
            yhxx2.S_QUSHUIYTBH = Convert.ToString(this.cmbQSYT2.Value);
            yhxx2.S_SHUIZIYBH = Convert.ToString(this.cmbSZYFQ2.Value);
            yhxx2.S_TIANJIAR = LoginInfo.CurrentUser.UserID.ToString();
            yhxx2.S_XINGZHENGQBH = this.cmbXZQ2.Value.ToString();
            yhxx2.S_YEWUY = this.cmbYWY2.Value.ToString();
            yhxx2.S_YINHANG = null;
            yhxx2.S_YONGHUH = this.txtYHH2.Text;
            yhxx2.S_YONGHUM = this.txtYHM2.Text;
            yhxx2.S_YOUBIAN = this.txtYB2.Text;
            yhxx2.S_YUANYONGHUH = laihanxx.S_YONGHUBH;
            yhxx2.S_ZHUANGBIAOJL = Convert.ToString(this.cmbZBJL2.Value);
            yhxx2.S_ZHUSHI = null;
            list.Add(yhxx2);
            //添加分户3
            if (this.cbQiYongFH3.Checked)
            {
                QS_LH_YONGHUTZ yhxx3 = new QS_LH_YONGHUTZ();
                yhxx3.I_NO = 3;
                yhxx3.D_CAOZUORQ = BusinessTool.GetDataBaseDateTime();
                yhxx3.D_TIANJIARQ = yhxx3.D_CAOZUORQ;
                yhxx3.I_BIAOSHI = (this.cbTS3.Checked ? 1 : 0);
                yhxx3.I_JLZT = 0;
                yhxx3.I_LAIHANLX = (int)this.LaiHanLX;
                yhxx3.I_WTYPE = BusinessTool.WType;
                yhxx3.I_YUANYONGH = 0;
                yhxx3.ID = 0;
                yhxx3.N_SHUIJIA = Convert.ToDecimal(this.txtYSJ3.Text);
                yhxx3.S_BUMENBH = BusinessTool.WType == 2 ? Convert.ToString(this.cmbZGBM3.Value) : "600";
                yhxx3.S_CAIWUDZ = this.txtCWDZ3.Text;
                yhxx3.S_CAIWUHM = this.txtCWHM3.Text;
                yhxx3.S_CAIWUYB = this.txtCWYB3.Text;
                yhxx3.S_CAOZUOR = LoginInfo.CurrentUser.UserID.ToString();
                yhxx3.S_DESTUSER = null;
                yhxx3.S_DIANHUA = this.txtLXDH3.Text;
                yhxx3.S_DIZHI = this.txtDZ3.Text;
                //yhxx3.S_FEETYPE = (this.cbTS3.Checked ? "3" : "0");
                yhxx3.S_FENPIANBH = Convert.ToString(this.cmbSLFP3.Value);
                yhxx3.S_HANGYEBH = Convert.ToString(this.cmbHYFL3.Value);
                yhxx3.S_HETONGH = Convert.ToString(this.txtHTH3.Text);
                yhxx3.S_HUANXIANBJ = Convert.ToString(this.cmbHXBJ3.Value);
                yhxx3.S_JIESHUNY = null;
                yhxx3.S_KAIHUH = this.txtKHZH3.Text;
                yhxx3.S_KAIHUHM = this.txtKHHM3.Text;
                yhxx3.S_KAIHUYH = this.txtKHYH3.Text;
                yhxx3.S_KAISHINY = null;
                yhxx3.S_LAIHANBH = laihanxx.S_LAIHANBH;
                yhxx3.S_LIANXIBM = this.txtLXBM3.Text;
                yhxx3.S_LIANXIR = this.txtLXR3.Text;
                yhxx3.S_LIUYUBH = Convert.ToString(this.cmbLY3.Value);
                yhxx3.S_QUSHUIYTBH = Convert.ToString(this.cmbQSYT3.Value);
                yhxx3.S_SHUIZIYBH = Convert.ToString(this.cmbSZYFQ3.Value);
                yhxx3.S_TIANJIAR = LoginInfo.CurrentUser.UserID.ToString();
                yhxx3.S_XINGZHENGQBH = this.cmbXZQ3.Value.ToString();
                yhxx3.S_YEWUY = this.cmbYWY3.Value.ToString();
                yhxx3.S_YINHANG = null;
                yhxx3.S_YONGHUH = this.txtYHH3.Text;
                yhxx3.S_YONGHUM = this.txtYHM3.Text;
                yhxx3.S_YOUBIAN = this.txtYB3.Text;
                yhxx3.S_YUANYONGHUH = laihanxx.S_YONGHUBH;
                yhxx3.S_ZHUANGBIAOJL = Convert.ToString(this.cmbZBJL3.Value);
                yhxx3.S_ZHUSHI = null;
                list.Add(yhxx3);
            }
            return list;
        }


        /// <summary>
        /// 生成原用户
        /// </summary>
        /// <returns></returns>
        private QS_LH_YONGHUTZ CreateYuanYongHu(YS_LH_LAIHANXX laihanxx)
        {
            QS_LH_YONGHUTZ yuanyonghu = new QS_LH_YONGHUTZ();
            DataRow drTemp = new QS_YG_YONGHUXXBLL().SelectQS_YG_YONGHUXXesDynamic("I_JLZT=0 AND S_YONGHUH=" + laihanxx.S_YONGHUBH, null).Rows[0];

            yuanyonghu.ID = 0;
            yuanyonghu.S_YONGHUH = Convert.ToString(drTemp["S_YONGHUH"]);
            yuanyonghu.S_XINGZHENGQBH = Convert.ToString(drTemp["S_XINGZHENGQBH"]);
            yuanyonghu.S_YONGHUM = Convert.ToString(drTemp["S_YONGHUM"]);
            yuanyonghu.S_DIZHI = Convert.ToString(drTemp["S_DIZHI"]);
            yuanyonghu.S_YOUBIAN = Convert.ToString(drTemp["S_YOUBIAN"]);
            yuanyonghu.S_LIANXIBM = Convert.ToString(drTemp["S_LIANXIBM"]);
            yuanyonghu.S_LIANXIR = Convert.ToString(drTemp["S_LIANXIR"]);
            yuanyonghu.S_KAIHUHM = Convert.ToString(drTemp["S_KAIHUHM"]);
            yuanyonghu.S_KAIHUYH = Convert.ToString(drTemp["S_KAIHUYH"]);
            yuanyonghu.S_YEWUY = Convert.ToString(drTemp["S_YEWUY"]);
            yuanyonghu.S_YUANYONGHUH = null;
            yuanyonghu.S_CAIWUDZ = Convert.ToString(drTemp["S_CAIWUDZ"]);
            yuanyonghu.S_CAIWUYB = Convert.ToString(drTemp["S_CAIWUYB"]);
            yuanyonghu.I_JLZT = Convert.ToDecimal(drTemp["I_JLZT"]);
            yuanyonghu.S_CAOZUOR = LoginInfo.CurrentUser.UserID.ToString();
            yuanyonghu.S_BUMENBH = Convert.ToString(drTemp["S_BUMENBH"]);
            yuanyonghu.S_DIANHUA = Convert.ToString(drTemp["S_DIANHUA"]);
            yuanyonghu.S_LIUYUBH = Convert.ToString(drTemp["S_LIUYUBH"]);
            yuanyonghu.S_SHUIZIYBH = Convert.ToString(drTemp["S_SHUIZIYBH"]);
            yuanyonghu.S_FENPIANBH = Convert.ToString(drTemp["S_FENPIANBH"]);
            yuanyonghu.S_HUANXIANBJ = Convert.ToString(drTemp["S_HUANXIANBJ"]);
            yuanyonghu.S_QUSHUIYTBH = Convert.ToString(drTemp["S_QUSHUIYTBH"]);
            yuanyonghu.S_HANGYEBH = Convert.ToString(drTemp["S_HANGYEBH"]);
            if (drTemp["N_SHUIJIA"] != DBNull.Value)
            {
                yuanyonghu.N_SHUIJIA = Convert.ToDecimal(drTemp["N_SHUIJIA"]);
            }
            yuanyonghu.I_BIAOSHI = Convert.ToDecimal(drTemp["I_BIAOSHI"]);
            yuanyonghu.S_KAIHUH = Convert.ToString(drTemp["S_KAIHUH"]);
            yuanyonghu.S_ZHUSHI = Convert.ToString(drTemp["S_ZHUSHI"]);
            yuanyonghu.I_WTYPE = Convert.ToDecimal(drTemp["I_WTYPE"]);
            yuanyonghu.S_TIANJIAR = Convert.ToString(drTemp["S_TIANJIAR"]);
            yuanyonghu.D_CAOZUORQ = BusinessTool.GetDataBaseDateTime();
            yuanyonghu.S_DESTUSER = Convert.ToString(drTemp["S_DESTUSER"]);
            yuanyonghu.S_KAISHINY = Convert.ToString(drTemp["S_KAISHINY"]);
            yuanyonghu.S_JIESHUNY = Convert.ToString(drTemp["S_JIESHUNY"]);
            yuanyonghu.S_HETONGH = Convert.ToString(drTemp["S_HETONGH"]);
            yuanyonghu.S_YINHANG = Convert.ToString(drTemp["S_YINHANG"]);
            yuanyonghu.S_CAIWUHM = Convert.ToString(drTemp["S_CAIWUHM"]);
            yuanyonghu.S_ZHUANGBIAOJL = Convert.ToString(drTemp["S_ZHUANGBIAOJL"]);
            yuanyonghu.S_FEETYPE = Convert.ToString(drTemp["S_FEETYPE"]);
            yuanyonghu.S_LAIHANBH = laihanxx.S_LAIHANBH;
            yuanyonghu.I_LAIHANLX = laihanxx.I_LAIHANLX;
            yuanyonghu.I_YUANYONGH = 1;

            return yuanyonghu;
        }

        public List<string> GetYHHList()
        {
            List<string> list = new List<string>();
            list.Add(this.txtYHH1.Text);
            list.Add(this.txtYHH2.Text);
            list.Add(this.txtYHH3.Text);
            return list;
        }


        #endregion

        /// <summary>
        /// 原用户号查询
        /// </summary>
        protected void btnActPerform_Click(object sender, EventArgs e)
        {
            //加载用户号
            DataRow dr = new QS_YG_YONGHUXXProcess().SelectQS_YG_YONGHUXXesDynamic("I_JLZT=0 AND S_YONGHUH='" + this.txtYongHuHYuan.Text + "' AND I_WTYPE=" + BusinessTool.WType, null).Rows[0];
            this.txtDZ1.Text = Convert.ToString(dr["S_DiZhi"]);
            this.txtHTH1.Text = Convert.ToString(dr["S_HETONGH"]);
            this.txtKHHM1.Text = Convert.ToString(dr["S_KAIHUHM"]);
            this.txtKHYH1.Text = Convert.ToString(dr["S_KAIHUYH"]);
            this.txtKHZH1.Text = Convert.ToString(dr["S_KAIHUH"]);
            this.txtLXBM1.Text = Convert.ToString(dr["S_LIANXIBM"]);
            this.txtLXDH1.Text = Convert.ToString(dr["S_DIANHUA"]);
            this.txtLXR1.Text = Convert.ToString(dr["S_LIANXIR"]);
            this.txtYHH1.Text = Convert.ToString(dr["S_YONGHUH"]);
            this.txtYHM1.Text = Convert.ToString(dr["S_YONGHUM"]);
            this.txtYB1.Text = Convert.ToString(dr["S_YOUBIAN"]);
            this.txtYSJ1.Text = Convert.ToString(dr["N_SHUIJIA"]);
            this.cbTS1.Checked = dr["I_BIAOSHI"] == DBNull.Value ? false : (Convert.ToInt32(dr["I_BIAOSHI"]) == 1);
            this.cmbXZQ1.Value = Convert.ToString(dr["S_XINGZHENGQBH"]);
            this.cmbYWY1.Value = Convert.ToString(dr["S_YEWUY"]);
            this.cmbHXBJ1.Value = Convert.ToString(dr["S_HUANXIANBJ"]);
            this.cmbLY1.Value = Convert.ToString(dr["S_LIUYUBH"]);
            this.cmbQSYT1.Value = Convert.ToString(dr["S_QUSHUIYTBH"]);
            this.cmbSLFP1.Value = Convert.ToString(dr["S_FENPIANBH"]);
            this.cmbSZYFQ1.Value = Convert.ToString(dr["S_SHUIZIYBH"]);
            this.cmbZBJL1.Value = Convert.ToString(dr["S_ZHUANGBIAOJL"]);
            this.cmbZGBM1.Value = Convert.ToString(dr["S_BUMENBH"]);
            //加载水表
            this.dtSource1 = new SpHelper().P_QS_BIAOXXHQBYYHH(this.txtYongHuHYuan.Text, BusinessTool.WType).Tables[0];
            this.BindData1();
        }

        protected void btn12_Click(object sender, EventArgs e)
        {
            if (this.dtSource1 == null || this.dtSource1.Rows.Count == 0)
            {
                return;
            }
            //记录选中的项在数据源中索引
            List<string> list = new List<string>();
            List<int> listIndex = new List<int>();
            for (int i = 0; i < this.gvList1.VisibleRowCount; i++)
            {
                ASPxCheckBox cb = (ASPxCheckBox)gvList1.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList1.Columns[0], "cb");
                HiddenField hf = (HiddenField)gvList1.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList1.Columns[0], "hfShuiBiaoBH");
                if (cb.Checked)
                {
                    list.Add(hf.Value);
                    listIndex.Add(i);
                }
            }
            if (listIndex.Count == 0)
            {
                return;
            }
            //数据源为NULL 初始化列
            if (this.dtSource2 == null)
            {
                this.dtSource2 = this.dtSource1.Copy();
                this.dtSource2.Clear();
            }
            //将选中的项添加到目标
            for (int i = 0; i < listIndex.Count; i++)
            {
                DataRow dr = this.dtSource2.NewRow();
                dr["S_SHUIBIAOH"] = this.dtSource1.Rows[listIndex[i]]["S_SHUIBIAOH"].ToString();
                dr["S_QUSHUIK"] = this.dtSource1.Rows[listIndex[i]]["S_QUSHUIK"].ToString();
                dr["S_LAOBIANH"] = this.dtSource1.Rows[listIndex[i]]["S_LAOBIANH"].ToString();
                this.dtSource2.Rows.Add(dr);
            }
            //重新制作源
            DataTable dtTemp = this.dtSource1.Copy();
            dtTemp.Clear();
            for (int i = 0; i < dtSource1.Rows.Count; i++)
            {
                bool isExists = false;
                for (int j = 0; j < listIndex.Count; j++)
                {
                    if (i == listIndex[j])
                    {
                        isExists = true;
                        break;
                    }
                }
                if (isExists == false)
                {
                    DataRow drT = dtTemp.NewRow();
                    drT["S_SHUIBIAOH"] = this.dtSource1.Rows[i]["S_SHUIBIAOH"].ToString();
                    drT["S_QUSHUIK"] = this.dtSource1.Rows[i]["S_QUSHUIK"].ToString();
                    drT["S_LAOBIANH"] = this.dtSource1.Rows[i]["S_LAOBIANH"].ToString();
                    dtTemp.Rows.Add(drT);
                }
            }
            this.dtSource1 = dtTemp.Copy();
            this.BindData1();
            this.BindData2();
        }
        protected void btn13_Click(object sender, EventArgs e)
        {
            if (this.dtSource1 == null || this.dtSource1.Rows.Count == 0)
            {
                return;
            }
            //记录选中的项在数据源中索引
            List<string> list = new List<string>();
            List<int> listIndex = new List<int>();
            for (int i = 0; i < this.gvList1.VisibleRowCount; i++)
            {
                ASPxCheckBox cb = (ASPxCheckBox)gvList1.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList1.Columns[0], "cb");
                HiddenField hf = (HiddenField)gvList1.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList1.Columns[0], "hfShuiBiaoBH");
                if (cb.Checked)
                {
                    list.Add(hf.Value);
                    listIndex.Add(i);
                }
            }
            if (listIndex.Count == 0)
            {
                return;
            }
            //数据源为NULL 初始化列
            if (this.dtSource3 == null)
            {
                this.dtSource3 = this.dtSource1.Copy();
                this.dtSource3.Clear();
            }
            //将选中的项添加到目标
            for (int i = 0; i < listIndex.Count; i++)
            {
                DataRow dr = this.dtSource3.NewRow();
                dr["S_SHUIBIAOH"] = this.dtSource1.Rows[listIndex[i]]["S_SHUIBIAOH"].ToString();
                dr["S_QUSHUIK"] = this.dtSource1.Rows[listIndex[i]]["S_QUSHUIK"].ToString();
                dr["S_LAOBIANH"] = this.dtSource1.Rows[listIndex[i]]["S_LAOBIANH"].ToString();
                this.dtSource3.Rows.Add(dr);
            }
            //重新制作源
            DataTable dtTemp = this.dtSource1.Copy();
            dtTemp.Clear();
            for (int i = 0; i < dtSource1.Rows.Count; i++)
            {
                bool isExists = false;
                for (int j = 0; j < listIndex.Count; j++)
                {
                    if (i == listIndex[j])
                    {
                        isExists = true;
                        break;
                    }
                }
                if (isExists == false)
                {
                    DataRow drT = dtTemp.NewRow();
                    drT["S_SHUIBIAOH"] = this.dtSource1.Rows[i]["S_SHUIBIAOH"].ToString();
                    drT["S_QUSHUIK"] = this.dtSource1.Rows[i]["S_QUSHUIK"].ToString();
                    drT["S_LAOBIANH"] = this.dtSource1.Rows[i]["S_LAOBIANH"].ToString();
                    dtTemp.Rows.Add(drT);
                }
            }
            this.dtSource1 = dtTemp.Copy();
            this.BindData1();
            this.BindData3();
        }
        protected void btn21_Click(object sender, EventArgs e)
        {
            if (this.dtSource2 == null || this.dtSource2.Rows.Count == 0)
            {
                return;
            }
            //记录选中的项在数据源中索引
            List<string> list = new List<string>();
            List<int> listIndex = new List<int>();
            for (int i = 0; i < this.gvList2.VisibleRowCount; i++)
            {
                ASPxCheckBox cb = (ASPxCheckBox)gvList2.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList2.Columns[0], "cb");
                HiddenField hf = (HiddenField)gvList2.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList2.Columns[0], "hfShuiBiaoBH");
                if (cb.Checked)
                {
                    list.Add(hf.Value);
                    listIndex.Add(i);
                }
            }
            if (listIndex.Count == 0)
            {
                return;
            }
            //数据源为NULL 初始化列
            if (this.dtSource1 == null)
            {
                this.dtSource1 = this.dtSource2.Copy();
                this.dtSource1.Clear();
            }
            //将选中的项添加到目标
            for (int i = 0; i < listIndex.Count; i++)
            {
                DataRow dr = this.dtSource1.NewRow();
                dr["S_SHUIBIAOH"] = this.dtSource2.Rows[listIndex[i]]["S_SHUIBIAOH"].ToString();
                dr["S_QUSHUIK"] = this.dtSource2.Rows[listIndex[i]]["S_QUSHUIK"].ToString();
                dr["S_LAOBIANH"] = this.dtSource2.Rows[listIndex[i]]["S_LAOBIANH"].ToString();
                this.dtSource1.Rows.Add(dr);
            }
            //重新制作源
            DataTable dtTemp = this.dtSource2.Copy();
            dtTemp.Clear();
            for (int i = 0; i < dtSource2.Rows.Count; i++)
            {
                bool isExists = false;
                for (int j = 0; j < listIndex.Count; j++)
                {
                    if (i == listIndex[j])
                    {
                        isExists = true;
                        break;
                    }
                }
                if (isExists == false)
                {
                    DataRow drT = dtTemp.NewRow();
                    drT["S_SHUIBIAOH"] = this.dtSource2.Rows[i]["S_SHUIBIAOH"].ToString();
                    drT["S_QUSHUIK"] = this.dtSource2.Rows[i]["S_QUSHUIK"].ToString();
                    drT["S_LAOBIANH"] = this.dtSource2.Rows[i]["S_LAOBIANH"].ToString();
                    dtTemp.Rows.Add(drT);
                }
            }
            this.dtSource2 = dtTemp.Copy();
            this.BindData2();
            this.BindData1();
        }
        protected void btn23_Click(object sender, EventArgs e)
        {
            if (this.dtSource2 == null || this.dtSource2.Rows.Count == 0)
            {
                return;
            }
            //记录选中的项在数据源中索引
            List<string> list = new List<string>();
            List<int> listIndex = new List<int>();
            for (int i = 0; i < this.gvList2.VisibleRowCount; i++)
            {
                ASPxCheckBox cb = (ASPxCheckBox)gvList2.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList2.Columns[0], "cb");
                HiddenField hf = (HiddenField)gvList2.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList2.Columns[0], "hfShuiBiaoBH");
                if (cb.Checked)
                {
                    list.Add(hf.Value);
                    listIndex.Add(i);
                }
            }
            if (listIndex.Count == 0)
            {
                return;
            }
            //数据源为NULL 初始化列
            if (this.dtSource3 == null)
            {
                this.dtSource3 = this.dtSource2.Copy();
                this.dtSource3.Clear();
            }
            //将选中的项添加到目标
            for (int i = 0; i < listIndex.Count; i++)
            {
                DataRow dr = this.dtSource3.NewRow();
                dr["S_SHUIBIAOH"] = this.dtSource2.Rows[listIndex[i]]["S_SHUIBIAOH"].ToString();
                dr["S_QUSHUIK"] = this.dtSource2.Rows[listIndex[i]]["S_QUSHUIK"].ToString();
                dr["S_LAOBIANH"] = this.dtSource2.Rows[listIndex[i]]["S_LAOBIANH"].ToString();
                this.dtSource3.Rows.Add(dr);
            }
            //重新制作源
            DataTable dtTemp = this.dtSource2.Copy();
            dtTemp.Clear();
            for (int i = 0; i < dtSource2.Rows.Count; i++)
            {
                bool isExists = false;
                for (int j = 0; j < listIndex.Count; j++)
                {
                    if (i == listIndex[j])
                    {
                        isExists = true;
                        break;
                    }
                }
                if (isExists == false)
                {
                    DataRow drT = dtTemp.NewRow();
                    drT["S_SHUIBIAOH"] = this.dtSource2.Rows[i]["S_SHUIBIAOH"].ToString();
                    drT["S_QUSHUIK"] = this.dtSource2.Rows[i]["S_QUSHUIK"].ToString();
                    drT["S_LAOBIANH"] = this.dtSource2.Rows[i]["S_LAOBIANH"].ToString();
                    dtTemp.Rows.Add(drT);
                }
            }
            this.dtSource2 = dtTemp.Copy();
            this.BindData2();
            this.BindData3();
        }
        protected void btn31_Click(object sender, EventArgs e)
        {
            if (this.dtSource3 == null || this.dtSource3.Rows.Count == 0)
            {
                return;
            }
            //记录选中的项在数据源中索引
            List<string> list = new List<string>();
            List<int> listIndex = new List<int>();
            for (int i = 0; i < this.gvList3.VisibleRowCount; i++)
            {
                ASPxCheckBox cb = (ASPxCheckBox)gvList3.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList3.Columns[0], "cb");
                HiddenField hf = (HiddenField)gvList3.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList3.Columns[0], "hfShuiBiaoBH");
                if (cb.Checked)
                {
                    list.Add(hf.Value);
                    listIndex.Add(i);
                }
            }
            if (listIndex.Count == 0)
            {
                return;
            }
            //数据源为NULL 初始化列
            if (this.dtSource1 == null)
            {
                this.dtSource1 = this.dtSource3.Copy();
                this.dtSource1.Clear();
            }
            //将选中的项添加到目标
            for (int i = 0; i < listIndex.Count; i++)
            {
                DataRow dr = this.dtSource1.NewRow();
                dr["S_SHUIBIAOH"] = this.dtSource3.Rows[listIndex[i]]["S_SHUIBIAOH"].ToString();
                dr["S_QUSHUIK"] = this.dtSource3.Rows[listIndex[i]]["S_QUSHUIK"].ToString();
                dr["S_LAOBIANH"] = this.dtSource3.Rows[listIndex[i]]["S_LAOBIANH"].ToString();
                this.dtSource1.Rows.Add(dr);
            }
            //重新制作源
            DataTable dtTemp = this.dtSource3.Copy();
            dtTemp.Clear();
            for (int i = 0; i < dtSource3.Rows.Count; i++)
            {
                bool isExists = false;
                for (int j = 0; j < listIndex.Count; j++)
                {
                    if (i == listIndex[j])
                    {
                        isExists = true;
                        break;
                    }
                }
                if (isExists == false)
                {
                    DataRow drT = dtTemp.NewRow();
                    drT["S_SHUIBIAOH"] = this.dtSource3.Rows[i]["S_SHUIBIAOH"].ToString();
                    drT["S_QUSHUIK"] = this.dtSource3.Rows[i]["S_QUSHUIK"].ToString();
                    drT["S_LAOBIANH"] = this.dtSource3.Rows[i]["S_LAOBIANH"].ToString();
                    dtTemp.Rows.Add(drT);
                }
            }
            this.dtSource3 = dtTemp.Copy();
            this.BindData3();
            this.BindData1();
        }
        protected void btn32_Click(object sender, EventArgs e)
        {
            if (this.dtSource3 == null || this.dtSource3.Rows.Count == 0)
            {
                return;
            }
            //记录选中的项在数据源中索引
            List<string> list = new List<string>();
            List<int> listIndex = new List<int>();
            for (int i = 0; i < this.gvList3.VisibleRowCount; i++)
            {
                ASPxCheckBox cb = (ASPxCheckBox)gvList3.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList3.Columns[0], "cb");
                HiddenField hf = (HiddenField)gvList3.FindRowCellTemplateControl(i, (GridViewDataColumn)gvList3.Columns[0], "hfShuiBiaoBH");
                if (cb.Checked)
                {
                    list.Add(hf.Value);
                    listIndex.Add(i);
                }
            }
            if (listIndex.Count == 0)
            {
                return;
            }
            //数据源为NULL 初始化列
            if (this.dtSource2 == null)
            {
                this.dtSource2 = this.dtSource3.Copy();
                this.dtSource2.Clear();
            }
            //将选中的项添加到目标
            for (int i = 0; i < listIndex.Count; i++)
            {
                DataRow dr = this.dtSource2.NewRow();
                dr["S_SHUIBIAOH"] = this.dtSource3.Rows[listIndex[i]]["S_SHUIBIAOH"].ToString();
                dr["S_QUSHUIK"] = this.dtSource3.Rows[listIndex[i]]["S_QUSHUIK"].ToString();
                dr["S_LAOBIANH"] = this.dtSource3.Rows[listIndex[i]]["S_LAOBIANH"].ToString();
                this.dtSource2.Rows.Add(dr);
            }
            //重新制作源
            DataTable dtTemp = this.dtSource3.Copy();
            dtTemp.Clear();
            for (int i = 0; i < dtSource3.Rows.Count; i++)
            {
                bool isExists = false;
                for (int j = 0; j < listIndex.Count; j++)
                {
                    if (i == listIndex[j])
                    {
                        isExists = true;
                        break;
                    }
                }
                if (isExists == false)
                {
                    DataRow drT = dtTemp.NewRow();
                    drT["S_SHUIBIAOH"] = this.dtSource3.Rows[i]["S_SHUIBIAOH"].ToString();
                    drT["S_QUSHUIK"] = this.dtSource3.Rows[i]["S_QUSHUIK"].ToString();
                    drT["S_LAOBIANH"] = this.dtSource3.Rows[i]["S_LAOBIANH"].ToString();
                    dtTemp.Rows.Add(drT);
                }
            }
            this.dtSource3 = dtTemp.Copy();
            this.BindData3();
            this.BindData2();
        }

    }
}